
<link rel="stylesheet" href="../../static/css/tpl/login.css"/>
<link rel="stylesheet" href="../../static/font-awesome/css/font-awesome.min.css"/>
<meta charset="utf-8"/>
<!--列表开始-->
<div class="main" ng-app="myApp" ng-controller="loginCtrl">
    <div class="login-top">
        <h1 style="margin-bottom: 20px">综合管理系统登录</h1>
    </div>
        <!--<form class="login">-->
          <!--<ul>-->
            <!--<li>-->
            <!--<i class="fa fa-user-circle "></i>-->
            <!--<input type="text" id="sfzmhm" class="login-input" placeholder="用户" autofocus value="">-->
            <!--</li>-->
            <!--<li>-->
            <!--<i class="fa fa-unlock-alt"></i>&nbsp;-->
            <!--<input type="password" id="LoginPWD" class="login-input" placeholder="密码" value="">-->
             <!--</li>-->
           <!--</ul>-->
            <!--<input type="submit" value="登 录" class="login-submit">-->
        <!--</form>-->
    <form class="login" ng-submit="onSubmit(myForm.$valid)" name="myForm" novalidate>
        <div class="l">
            <label>
                <i class="fa fa-user-circle "></i>
                <input type="text" id="user" placeholder="用户"  required  ng-model="user">
                <div ng-show="myForm.user.$invalid && submitted">
                    <div style="color: red" ng-show="myForm.user.$error.required">用户名不能为空！</div>
                </div>
            </label>
            <label>
                <i class="fa fa-unlock-alt"></i>
                <input type="password" name="password" id="password" placeholder="密码" ng-model="password" value="">
                <div ng-show="myForm.password.$invalid && submitted">
                    <div style="color: red" ng-show="myForm.password.$error.required">密码不能为空！</div>
                </div>
            </label>

            <input  ng-disabled="myForm.$invalid" type="submit" value="登 录" class="login-submit">

        </div>

    </form>
</div>
<script src="../../static/libs/angular.js"></script>
<script src="../../static/libs/angular-ui-router.min.js"></script>
<script src="../../static/libs/jquery-1.11.3.js"></script>
<script src="../../static/libs/angular-cookies.min.js"></script>
<script>
    'use strict';
    var myApp=angular.module('myApp',['ng','ngCookies']);
    myApp.controller('loginCtrl',['$scope','$http','$cookieStore','$window',function($scope,$http,$cookieStore,$window){
        $scope.submitted=false;
        $scope.onSubmit=function(){
            var param={
                name:$scope.user,
                password:$scope.password
            };
//            $http.post('http://192.168.1.6:8080/api/login',param)
            $http.post('http://192.168.1.12:8090/motor-vehicle-examination-rest/api/login', param)
                    .then(function(data){
                        var data=data.data;
                        $cookieStore.put('key',data.key);
                        $cookieStore.put('user',data.user);
                        $cookieStore.put('password',data.password);
                        $cookieStore.put("param", {
                            user: "admin",
                            pwd: 123456
                        });
                        $scope.person=$cookieStore.get("param");
                        $window.location.href="https://www.baidu.com";
                        console.log(data);
                       // 这里验证用户名存在不
                    })
                    .catch(function(){
                        console.log('ajax请求出错！')
                    })
        }
    }]);
</script>


